//
// CVisualCollisionManager.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;

public class CVisualCollisionManager {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CVisualCollisionManager(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CVisualCollisionManager obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CVisualCollisionManager(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CVisualCollisionManager() {
    this(nel3dJNI.new_CVisualCollisionManager(), true);
  }

  public void setLandscape(CLandscape landscape) {
    nel3dJNI.CVisualCollisionManager_setLandscape(swigCPtr, this, CLandscape.getCPtr(landscape), landscape);
  }

  public CVisualCollisionEntity createEntity() {
    long cPtr = nel3dJNI.CVisualCollisionManager_createEntity(swigCPtr, this);
    return (cPtr == 0) ? null : new CVisualCollisionEntity(cPtr, false);
  }

  public void deleteEntity(CVisualCollisionEntity entity) {
    nel3dJNI.CVisualCollisionManager_deleteEntity(swigCPtr, this, CVisualCollisionEntity.getCPtr(entity), entity);
  }

  public void setSunContributionPower(float power, float maxThreshold) {
    nel3dJNI.CVisualCollisionManager_setSunContributionPower(swigCPtr, this, power, maxThreshold);
  }

  public void setPlayerInside(boolean state) {
    nel3dJNI.CVisualCollisionManager_setPlayerInside(swigCPtr, this, state);
  }

  public float getCameraCollision(CVector start, CVector end, float radius, boolean cone) {
    return nel3dJNI.CVisualCollisionManager_getCameraCollision(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end, radius, cone);
  }

  public boolean getRayCollision(CVector start, CVector end, boolean landscapeOnly) {
    return nel3dJNI.CVisualCollisionManager_getRayCollision__SWIG_0(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end, landscapeOnly);
  }

  public boolean getRayCollision(CVector start, CVector end) {
    return nel3dJNI.CVisualCollisionManager_getRayCollision__SWIG_1(swigCPtr, this, CVector.getCPtr(start), start, CVector.getCPtr(end), end);
  }

  public long addMeshInstanceCollision(CVisualCollisionMesh mesh, SWIGTYPE_p_NLMISC__CMatrix instanceMatrix, boolean avoidCollisionWhenInside, boolean avoidCollisionWhenOutside) {
    return nel3dJNI.CVisualCollisionManager_addMeshInstanceCollision(swigCPtr, this, CVisualCollisionMesh.getCPtr(mesh), mesh, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(instanceMatrix), avoidCollisionWhenInside, avoidCollisionWhenOutside);
  }

  public void removeMeshCollision(long id) {
    nel3dJNI.CVisualCollisionManager_removeMeshCollision(swigCPtr, this, id);
  }

  public void receiveShadowMap(IDriver drv, CShadowMap shadowMap, CVector casterPos, CMaterial shadowMat, CShadowMapProjector smp) {
    nel3dJNI.CVisualCollisionManager_receiveShadowMap(swigCPtr, this, IDriver.getCPtr(drv), drv, CShadowMap.getCPtr(shadowMap), shadowMap, CVector.getCPtr(casterPos), casterPos, CMaterial.getCPtr(shadowMat), shadowMat, CShadowMapProjector.getCPtr(smp), smp);
  }

  public void getMeshs(SWIGTYPE_p_NLMISC__CAABBox aabbox, SWIGTYPE_p_std__vectorT_NL3D__CMeshInstanceColInfo_t dest) {
    nel3dJNI.CVisualCollisionManager_getMeshs(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(aabbox), SWIGTYPE_p_std__vectorT_NL3D__CMeshInstanceColInfo_t.getCPtr(dest));
  }

}
